package com.xingzhe.content.api;

import com.xingzhe.content.mapper.CourseTeacherMapper;
import com.xingzhe.content.model.po.CourseTeacher;
import com.xingzhe.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 课程教师管理相关接口
 */
@Api(value = "课程教师管理接口",tags = "课程教师管理接口")
@RestController
public class CourseTeacherController {
    @Resource
    private CourseTeacherService courseTeacherService;
    @Resource
    private CourseTeacherMapper courseTeacherMapper;

     // /courseTeacher/list/138
    @ApiOperation("查询本课程的所有教师")
    @GetMapping("/courseTeacher/list/{courseId}")
    public List<CourseTeacher> findAllTeacher(@PathVariable(value = "courseId")Long courseId){
        return courseTeacherService.findAll(courseId);
    }

    // /courseTeacher
    @ApiOperation("新增或修改本课程的教师")
    @PostMapping("/courseTeacher")
    public void saveCourseTeacher(@RequestBody CourseTeacher courseTeacher){
        //假设一个机构id
        Long companyId=1232141425L;
        courseTeacherService.saveOrUpdateCourseTeacher(courseTeacher,companyId);
    }

    // /courseTeacher/course/138/23
    @ApiOperation("删除本课程的教师")
    @DeleteMapping("/courseTeacher/course/{courseId}/{teacherId}")
    public void deleteCourseTeacher(@PathVariable(value = "courseId")Long courseId,
                                    @PathVariable(value = "teacherId")Long teacherId){
        //假设一个机构id
        Long companyId=1232141425L;
        courseTeacherService.deleteCourseTeacher(courseId, teacherId,companyId);
    }
}
